package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.IntStream;

/**
 * @Author @fiber-cloud
 * @Date 2025/10/7 11:40
 */
public class IODemo6 {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = new FileInputStream("D:/test.txt");

//        while (true){
//            int b = inputStream.read();
//            if (b == -1){
//                break;
//            }
//            System.out.printf("%c",b);
//        }
//        inputStream.close();

        //一次读1024个字节
//        while (true){
//            byte[] buffer = new byte[1024];
//            int len = inputStream.read(buffer);
//            System.out.println("len: "+len);
//            if (len == -1){
//                break;
//            }
//            for (int i = 0; i < len; i++) {
//                System.out.printf("%x\n",buffer[i]);
//            }
//        }



        //一次读一个字节
        while (true){
            int b = inputStream.read();
            if (b == -1){
                break;
            }
            System.out.printf("%x\n",b);
        }


    }

}
